<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="">
    <input type="text" name="info">
    <input type="button" value="提交" @click="fn()">
</form>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v=new Vue({
        el:"form",
        data:{},
        methods:{
            fn:function () {
               // alert("xxx");
                //当请求带参数并且参数是从from表单中获取时 使用post请求 反之使用get
                //创建Form表单数据对象
                let data=new FormData(document.querySelector("form"));
                //发出异步post请求
                axios.post("/testPost",data).then(function (response) {
                    alert(response.data);
                });
            }
        }
    })
</script>
</body>
</html>